package com.tedu.springmvc.controller;

import com.tedu.springmvc.pojo.dto.BmiDTO;
import com.tedu.springmvc.pojo.entity.Bmi;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Mapper
@Controller
public class BmiController {
    @ResponseBody
    @RequestMapping("/bmi")
    public String bmi(Bmi dto) {
        Double bmi = dto.getWeight() / (dto.getHeight() * dto.getHeight());
        if (bmi < 18.5){
            return "过轻";
        }else if (bmi < 24){
            return "正常";
        }else if (bmi < 27){
            return "微胖";
        }else{
            return "该减肥了";
        }
    }
}
